/**============================================================================
 Confidential Information - Limited distribution to authorized persons only.
 This software is protected as an unpublished work under the U.S. Copyright
 Act of 1976.

 Copyright (c) 2011, BluePhoenix Solutions, Inc. All rights reserved.
 ----------------------------------------------------------------------------
 file......: TableModelInfo.java
 Author....: Vyacheslav Kovalyov
 Created...: 26.10.11

 Description:

 ============================================================================*/
package ru.monyag.pred.swing.ui.table;

import java.util.Vector;

/**
 * @author Vyacheslav Kovalyov
 * @version 1.0
 */
public abstract class TableModelInfo {

    protected TableModelInfo() {
        this.infos = new Vector<TableColumnInfo>();
    }

    private TableModelInfo add(TableColumnInfo info) {
        infos.add(info);
        return this;
    }

    protected TableModelInfo add(int id, String columnName) {
        return add(id, columnName, null);
    }

    protected TableModelInfo add(int id, String columnName, Integer width) {
        return add(new TableColumnInfo(id, columnName, width));
    }

    public Vector<String> getColumnNames() {

        Vector<String> list = new Vector<String>();

        for (TableColumnInfo info : infos) {
            list.add(info.getColumnName());
        }

        return list;
    }

    public int getColumnsCount() {
        return infos.size();
    }

    public Integer getColumnWidth(int i) {
        return infos.get(i).getWidth();
    }

    private final Vector<TableColumnInfo> infos;
}
